package com.shop.service.impl;

import com.shop.bean.Admin;
import com.shop.bean.User;
import com.shop.dao.AdminDao;
import com.shop.dao.UserDao;
import com.shop.service.ISystemLoginService;
import com.shop.util.SYS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class SystemLoginService implements ISystemLoginService {

    @Autowired
    AdminDao adminDao;


    @Override
    public Admin dologin(Admin admin) {
        Admin admin_data=adminDao.getAdminByUsername(admin.getUsername());
        if(admin_data==null){
            throw new RuntimeException("没有此账号");
        }

        if(!SYS.checkPass(admin.getPassword(),admin_data.getPassword())){
            throw new RuntimeException("密码不正确");
        }
        return admin_data;
    }
}
